package com.footprint.common.httpclient;

import java.io.IOException;

import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;

import com.footprint.common.util.Constants;

public class FareSearchClient implements HttpClientInterface {
	private BasicHttpResponse response;
	private ResponseHandler respHandler;
	private HttpClient client;

	public FareSearchClient() {
		client = new DefaultHttpClient();
		response = new BasicHttpResponse();
	}


	public void setHttpResponse(BasicHttpResponse response) {
		this.response = response;
	}

	public void getFare() {

		try {
			respHandler.handleWithResponse(response.getResponse());
		} catch (IllegalStateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Override
	public HttpResponseInterface execute(HttpRequestInterface request)
			throws Exception {
		response.setHttpResponse(this.client.execute(request.getUriRequest()));
		return this.response;
	}



}
